package mars.wizards;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;

/**
 * The "New" wizard page allows setting the container for the new file as well
 * as the file name. The page will only accept file name without the extension
 * OR with the extension that matches the expected one (mpe).
 */

public class WidgetNewWizardPage extends WizardPage {
	private Text containerText;

	private Text fileText;

	private ISelection selection;
	private IWorkspaceRoot workspaceRoot;

	/**
	 * Constructor for SampleNewWizardPage.
	 * 
	 * @param pageName
	 */
	public WidgetNewWizardPage(ISelection selection) {
		super("widget-Create a New Widget");
		setTitle("widget-Create a New Widget");
		setDescription("widget-Create a New Widget");
		setPageComplete(false);
		workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	}

	/**
	 * @see IDialogPage#createControl(Composite)
	 */
	public void createControl(Composite parent) {
		initializeDialogUnits(parent);
		final Composite composite = createClientArea(parent);
		createLabel(composite);
		setControl(composite);
		Dialog.applyDialogFont(composite);

	}

	/** */
	/**
	 * 
	 * @param composite
	 * @return
	 */
	private Composite createClientArea(Composite composite) {
		Composite composite1 = new Composite(composite, SWT.NONE);
		GridLayout gridlayout = new GridLayout();
		gridlayout.marginWidth = 0;
		gridlayout.marginHeight = 0;
		gridlayout.numColumns = 3;
		composite1.setLayout(gridlayout);
		return composite1;
	}

	/** */
	/**
	 * 
	 * @param composite
	 */
	private void createLabel(Composite composite) {
		Label label = new Label(composite, 64);
		label.setText("Label");
		GridData griddata = new GridData();
		griddata.widthHint = convertWidthInCharsToPixels(80);
		griddata.horizontalSpan = 3;
		label.setLayoutData(griddata);
	}

	

	private void updateStatus(String message) {
		setErrorMessage(message);
		setPageComplete(message == null);
	}

	public String getContainerName() {
		return containerText.getText();
	}

	public String getFileName() {
		return fileText.getText();
	}
}